package com.woniu.user.controller;

import com.woniu.common.util.ResponseData;
import com.woniu.user.pojo.TUser;
import com.woniu.user.service.TUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 杜梅杰
 * @description
 * @date 2024/5/8 15:10
 */
@RestController
@Api(tags = "登录API")
public class LoginController {
    @Autowired
    private TUserService userService;

    @PostMapping("/login")
    @ApiOperation(value = "登录", tags = "登录")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "username", value = "账号", required = true),
            @ApiImplicitParam(name = "pwd", value = "密码", required = true),
    })
    public ResponseData<TUser> login(String username, String pwd) {
        return userService.login(username, pwd);
    }


    /**
     * 通过token查询app用户信息
     */
    @PostMapping("/getAppUserInfo")
    public ResponseData<?> getAppUserInfo(String token){
        return userService.getAppUserInfo(token);
    }

}
